package xyz.mumuwei.youthcourseserver.pojo;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * <p>
 * 
 * </p>
 *
 * @author mumuwei
 * @since 2022-02-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 微信绑定后的唯一标识id
     */
    @Size(max = 128, message = "openId长度有无")
    private String openId;

    /**
     * 用户名
     */
    @Size(min = 6, message = "用户名长度不能少于6位")
    private String username;

    /**
     * 密码
     */
    private String keyword;

    /**
     * 头像id
     */
    private Integer avatarId;

    /**
     * 头像地址
     */
    @TableField(exist = false)
    private String avatar;

    /**
     * 邮箱
     */
    @Email(message = "邮箱格式有误")
    private String email;

    /**
     * 手机号
     */
    @Pattern(regexp = "/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$/", message = "手机号码格式有误")
    private String phone;

    /**
     * 角色id
     */
    private Integer roleId;

    /**
     * 上次登录时间
     */
    private String lastLoginTime;

    /**
     * 上次登录ip
     */
    private byte[] lastLoginIp;

    /**
     * 状态: 0：正常,  1：锁定
     */
    private Integer state;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private String createTime;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateTime;

    /**
     * 逻辑删除: 0：正常,  1：删除
     */
    @TableLogic
    private Integer isDelete;

    /**
     * 用户token
     */
    @TableField(exist = false)
    private String token;

    /**
     * 用户真实姓名
     */
    @TableField(exist = false)
    private String realName;

    /**
     * 角色编码
     */
    @TableField(exist = false)
    private String roleCode;

    /**
     * 角色名
     */
    @TableField(exist = false)
    private String roleName;
}
